package com.engine4cloud.tdf.supervision.service.impl;

import com.engine4cloud.tdf.common.security.service.TdfUser;
import com.engine4cloud.tdf.common.security.util.SecurityUtils;
import com.engine4cloud.tdf.supervision.convert.ActiveAuditConvert;
import com.engine4cloud.tdf.supervision.dto.create.SpAuditResultCreateDTO;
import com.engine4cloud.tdf.supervision.service.SpAuditResultService;
import com.engine4cloud.tdf.supervision.service.SpFinishService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 结束接口
 */
@Service
public class SpFinishServiceImpl implements SpFinishService {

    @Resource
    private SpAuditResultService auditResultService;

    @Override
    public Boolean finish(SpAuditResultCreateDTO dto) {
        TdfUser user = SecurityUtils.getUser();
        return auditResultService.save(
                ActiveAuditConvert.INSTANCE.create(
                        dto,
                        user.getUsername(),
                        user.getTenantId(),
                        user.getDeptId()));
    }

    @Override
    public Boolean cancel(SpAuditResultCreateDTO dto) {
        TdfUser user = SecurityUtils.getUser();
        return auditResultService.save(
                ActiveAuditConvert.INSTANCE.create(
                        dto,
                        user.getUsername(),
                        user.getTenantId(),
                        user.getDeptId()));
    }
}